<template>
	<view class="voucher">
		<view class="voucher_left" :class="{'voucher_left_active':textHidden}">
			<view class="voucher_left_left">
				<text>899</text>
				<view class="money">￥</view>
			</view>
			<view class="voucher_left_right">
				<view class="bar"></view>
				<text>新风尚优惠券</text>
				<text>满2000减899</text>
			</view>
		</view>
		<view class="voucher_right" @click="receive" :class="{'voucher_right_active':textHidden}"><text>{{text}}</text></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				textHidden:false,
				text:'点击领取',
			}
		},
		methods: {
			receive(){
				if(this.text == '点击领取') {
					uni.showToast({
						title:'领取成功',
						icon:'success',
					});
					this.text = '已领取';
					this.textHidden = true;
				}else if(this.text == '已领取') {
					uni.showToast({
						title:'已经领取过啦',
						icon:'none',
					});
				}
			}
		},
	}
</script>

<style lang="scss" scoped>
	.voucher {
		width: 616rpx;
		height: 164rpx;
		border-radius: 10rpx;
		margin-top: 42rpx;
		position: relative;
		
		&_left {
			width: 536rpx;
			height: 164rpx;
			background: #F9F6F3;
			border-radius: 10rpx;
			position: relative;
			left: 0rpx;
			top: 0rpx;
			z-index: 2;
			display: flex;
			align-items: center;
			
			&_left {
				flex: 1;
				height: 100%;
				display: flex;
				justify-content: center;
				align-items: center;
				position: relative;
				
				text {
					font-size: 120rpx;
					color: #CBAF87;
				}
				
				.money {
					font-size: 38rpx;
					color: #CBAF87;
					position: absolute;
					right: 0rpx;
					top: 0rpx;
				}
			}
			
			&_right {
				flex: 1;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-wrap: wrap;
				position: relative;
				
				.bar {
					width: 0rpx;
					height: 38rpx;
					border: 2rpx solid rgba($color: #CBAF87, $alpha: 0.5);
					position: absolute;
					left: 14rpx;
					top: 14rpx;
				}
				
				text {
					font-size: 24rpx;
					color: #333333;
				}
			}
			
			&::before {
				content: '';
				display: block;
				width: 50rpx;
				height: 50rpx;
				background: #fff;
				border-radius: 50%;
				position: absolute;
				left: -24rpx;
				top: 58rpx;
			}
			
			&::after {
				content: '';
				display: block;
				width: 50rpx;
				height: 50rpx;
				background: #CBAF87;
				border-radius: 50%;
				position: absolute;
				right: -24rpx;
				top: 58rpx;
			}
		}
		
		.voucher_left_active {
			
			&::after {
				content: '';
				background: #BCBCBC;
			}
		}
		
		&_right {
			width: 110rpx;
			height: 164rpx;
			background: #CBAF87;
			border-radius: 10rpx;
			position: absolute;
			right: 0rpx;
			top: 0rpx;
			z-index: 1;
			display: flex;
			justify-content: flex-end;
			align-items: center;
			
			text {
				display: inline-block;
				width: 32rpx;
				float: right;
				margin-right: 24rpx;
				font-size: 26rpx;
				color: #FFFFFF;
			}
		}
		.voucher_right_active {
			background-color: #BCBCBC !important;
			
			text {
				color: #000;
			}
		}
		
		&:last-child {
			margin-bottom: 42rpx;
		}
	}
</style>
